.th PUTC III 6/12/72
.sh NAME
putc, putw, fcreat, fflush  \*-  buffered output
.sh SYNOPSIS
.ft B
.nf
mov	$filename,r0
jsr	r5,fcreat; iobuf
.s3
fcreat(file, iobuf)
char *file;
struct buf *iobuf;
.s3
.ft R
(get byte in r0)
.ft B
jsr	r5,putc; iobuf
.s3
putc(c, iobuf)
int c;
struct buf *iobuf;
.s3
.ft R
(get word in r0)
.ft B
jsr	r5,putw; iobuf
.s3
putw(w, iobuf);
.br
int w;
.br
struct buf *iobuf;
.s3
jsr	r5,flush; iobuf
.s3
fflush(iobuf)
struct buf *iobuf;
.fi
.ft R
.sh DESCRIPTION
.it Fcreat
creates
the given file (mode 666) and sets up the buffer
.it iobuf
(size 518 bytes);
.it putc
and
.it putw
write a byte or word respectively
onto the file;
.it flush
forces the contents of the buffer to be written, but
does not close the file.
The structure of the buffer is:
.nf
.ft B
.nf
struct buf {
	int fildes;	/* File descriptor */
	int nunused;	/* Remaining slots */
	char *xfree;	/* Ptr to next free slot */
	char buff[512];	/* The buffer */
};
.ft R
.s3
.fi
Before terminating, a program should call
.it flush
to force out the last of the output
.it (fflush
from C).
.s3
The user must supply
.it iobuf,
which should begin on a word boundary.
.s3
To write a new file using the same buffer, it
suffices to call
.it [f]flush,
close the file,
and
call
.it fcreat
again.
.sh "SEE ALSO"
creat (II), write (II), getc (III)
.sh DIAGNOSTICS
.it Fcreat
sets the error bit (c-bit) if the 
file creation failed (from C, returns \*-1).
.it Putc
and
.it putw
return their character (word) argument.
In all calls 
.it errno
is set appropriately to 0 or to
a system error number.
See introduction (II).
.sh BUGS
